package com.atguigu.gmall0722.customer.demo.controller;


import com.atguigu.gmall0722.customer.demo.bean.Customer;
import com.atguigu.gmall0722.customer.demo.service.CustomerService;
import com.atguigu.gmall0722.customer.demo.service.impl.CustomerServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
public class CustomerController {

    @Autowired
    @Qualifier("service1")
    CustomerService customerService;



    //路径后键值对参数 ：  场景：查询条件
    @RequestMapping("/sayhello")
    public  String sayHello(@RequestParam(value = "name",required = false,defaultValue = "no name") String name ){
        return  "hello world !!!  name:"+name;
    }

   //路径中的参数 ：    场景： 主键查询
    @RequestMapping("/customer/{id}")
    public String getCustomer(@PathVariable("id") String id){
        return  "customer id :"+id;
    }


    //请求体中的参数：  场景： 数据提交保存
    @PostMapping("/customer")
    public String saveCustomer(@RequestBody Customer customer){
        int i = 10 / customer.getAge();
        customerService.saveCustomer(customer);
        return  "success";
    }


}
